<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/res/back/css/base.css" rel="stylesheet" type="text/css" />
<link href="/res/third/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>

<style>
.noselect{
	background-color: rgba(99, 230, 99, 0.8);
}
.achecked{
	background-color: green;
}
.panel-body.panel-body-noheader.panel-body-noborder{
    overflow-y: hidden;
}
</style>	
</head>
<body id="easyui-layout"  class="easyui-layout"  >
    <div data-options="region:'north'" >
        <div>
            <button onclick="validAll()" class="btn  btn-sm btn-success" style="margin: 5px;r"  >合并提交</button>
            <span style="color: red;" >*删除tab表示该tab内的全部舍弃</span>
        </div>
    </div>
    <div data-options="region:'center',split:false">
        <div id="excelTab" class="easyui-tabs" fit="true" border="false">

        </div>
    </div>
<script>


    function validAll() {

        var flag = false;
        var data =null;
        $("iframe[name='excelframe']").each(function (i) {
            var iframe = $(this)[0];
            flag = iframe.contentWindow.validBeforeSub();
            if(!flag){
                var name = $(this).attr("class");
                $('#excelTab').tabs('select', name);
                return false;
            }else{
                var obj = iframe.contentWindow.createData();
                if(data==null){
                    data=obj;
                }else{
                    $.each(obj.item,function () {
                        data.item.push(this);
                    });

                    $.each(obj.typenames,function () {
                        data.typenames.push(this);
                    });

                    $.each(obj.oldtitles,function () {
                        data.oldtitles.push(this);
                    });
                }
            }
        });

        if(flag){
            //设置后提交
            art.dialog.post({
                url:"/enq/o_saveitem.do",
                data:JSON.stringify(data),
                contentType:"application/json",
                success:function(data){
                    if(data.success){
                        //refresh();
                        //更新原
                        art.dialog.alert("操作成功",function(){
                            top.closeTempTab(true);
                        })
                    }else{
                        art.dialog.tips(data.msg);
                    }
                }
            });

        }
    }

    $('#excelTab').tabs({
        border:false
    });


    function addTabExcel(subtitle, url,i) {
        if (!$('#excelTab').tabs('exists', subtitle)) {
            $('#excelTab').tabs('add',{
                title : subtitle,
                content : createFrameExcel(url,i),
                closable : true
            });
        }
        return false;
    }
    function createFrameExcel(url,i) {
        var s = '<iframe  class="excel_model_'+i+'"  name="excelframe"  frameborder="no" border="0″ marginwidth="0″ marginheight="0″ scrolling="no" allowtransparency="yes"  height="100%"  src="'+url+'" style="width:100%;height:100%;"></iframe>';
        return s;
    }

    var mulitysize = ${wrapsize!0};
    for(var i=0;i<mulitysize;i++){
        addTabExcel("excel_model_"+i,"/enquiry/mulity_one.do?index="+i+"&enqid=${enquiry.id}",i);
    }
</script>
</body>

</html>